package com.atguigu.gmall.feign.retry;

import feign.RetryableException;
import feign.Retryer;

/**
 * @author lfy
 * @Description
 * @create 2022-10-21 9:37
 */
public class MyNeverRetryer implements Retryer {

    int start = 1;
    int end = 10;
    //决定是否重试
    @Override
    public void continueOrPropagate(RetryableException e) {
        //永不重试
        throw  e;

        //通过抛异常进行中断即可
//        System.out.println("重试器开始工作....");
////        throw  e;  无限重试，直到成功
//        if(start++>end){
//            throw  e;
//        }
        //间隔 500ms 再试一次
//        Thread.sleep(500);
        //有限次数重试
    }

    @Override
    public Retryer clone() {
        return new MyNeverRetryer();
    }
}
